package com.cqsd;

import com.cqsd.entry.a.b.c.EmpService;
import com.cqsd.ioc.annotation.Component;
import com.cqsd.ioc.trait.use.BeanRun;
import com.cqsd.ioc.trait.use.InitalizingBean;

import java.util.concurrent.TimeUnit;

/**
 * @author caseycheng
 * @date 2023/3/13-19:31
 **/
@Component
public class ShopService implements InitalizingBean, BeanRun {
    private final EmpService empService;
    private final UserService userService;

    public ShopService(EmpService empService, UserService userService) {
        this.empService = empService;
        this.userService = userService;
    }

    @Override
    public void afterPropertiesSet() {
        System.out.println("empService = " + empService);
        System.out.println("userService = " + userService);
    }


    @Override
    public Runnable run() {
        System.out.println("------------------------------------------------");
        System.out.println("我是ShopService对象，我在调用empService的fac方法");
        empService.fac();
        System.out.println("我是shopService对象，我要睡5秒");
        try {
            TimeUnit.SECONDS.sleep(5);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("我是shopService对象，我起床了");
        return null;
    }

}
